*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*	This is the Master program for cleaning the NYC raw data.
*	----------------------------------------------------------------------------

	clear all
	set more off
	set maxvar 	32767
	set matsize 11000

*	paths

	global rawdata 				"${data_raw_NYC}"
	global cleandata 			"${data_clean_NYC}"

* settings

	local bw 					"ccftcovs_bwall"

* switches

	local convert 				1	//transform txts into dta files and eliminate
	local enrollment 	 		1 	//clean the enrollment file
	local baselines				1 	//clean baseline scores
	local tests					1 	//clean outcome tests (sat)
	local match 				1 	//clean match file
	local pscores 				1	//calculate pscores
		local mdrd2 		1		//mdrd2 pscores (bw and rv options in pscores.do)
		local mdrd1 		1		//mdrd1 pscores
		local prgs 			1		//save program-level pscores
		local schs 			1		//save school-level pscores
	local compile				1	//compile cleaned raw data

*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* do

	// txt to dta
	if `convert'  				do "${code_clean_NYC}c_convert"

	// clean enrollment
	if `enrollment' 			do "${code_clean_NYC}c_enrollment"

	// clean Baseline Scores
	if `baselines' 				do "${code_clean_NYC}c_baselines"

	// cleaning outcome test scores
	if `tests' 					do "${code_clean_NYC}c_tests"

	// clean match file
	if `match' 					do "${code_clean_NYC}c_match"

	// create pscores
	if `pscores' 				do "${code_clean_NYC}c_pscores" `mdrd2' `mdrd1' `prgs' `schs' `bw'

	// compile the basefile
	if `compile' 				do "${code_clean_NYC}c_compile" `bw'
